package com.vito.framework.base.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FilterConfig {

    @Autowired
    private AppLogFilter appLogFilter;

    @Bean
    public FilterRegistrationBean<AppLogFilter> registerAuthFilter() {
        FilterRegistrationBean<AppLogFilter> registration = new FilterRegistrationBean<AppLogFilter>();
        registration.setFilter(appLogFilter);
        registration.addUrlPatterns("/*");
        registration.setName("appLogFilter");
        registration.setOrder(1); //值越小，Filter越靠前。
        return registration;
    }

    //如果有多个Filter，再写一个public FilterRegistrationBean registerOtherFilter(){...}即可。

}
